Integration Guide Universal Robots LS
Note: We strongly recommend that you read the Robot communication overview before this integration guide.
Note 2: We strongly recommend that you use the latest version of this integration guide. It is included in the latest version of the Robot module. To download the Robot module, visit the official Photoneo website.
Contents
1 Prerequisites
This guide describes the Robot module for robots running PolyScope 5. Before you start the setup, make sure that your robot controller meets these requirements:
E-Series controller with software version 5.10 or higher
UR-Series controller - the supported software versions are not defined yet
CB-Series controller - no longer officially supported
RTDE service enabled on the robot (see 2.2)
Photoneo vision controller with Locator Studio (LS) 1.5
This version of the robot interface was developed and tested with Universal Robots E-Series v5.22 and v5.11.
Robots with PolyScope X use a separate Robot module. It is described in its own integration guide.
To check the software version of your robot, go to Menu -> About:
The UR software version is listed on the first line:
2 Robot controller setup
2.1 Network configuration
First, configure the IP address of the robot controller port that communicates with the Photoneo vision controller. Go to Menu -> Settings:
Open System -> Network. Select Static Address as the network method and enter the IP address and Subnet Mask of the robot controller. This manual uses 192.168.1.2 and 255.255.255.0. Click Apply to confirm the changes.
Note: The subnet mask 255.255.255.0 is the same as a 24-bit subnet mask. For more combinations, see this table.
Example of a matching network configuration on the vision controller side:
Vision controller IPv4 address: 192.168.1.1 / 24
Robot controller IPv4 address: 192.168.1.2 / 24 (as configured in the previous step)
You can also use the Test Connection button on the Network page of the Photoneo vision controller to ping the Universal Robots controller.
Depending on the result of the test connection (ping command), you get a Robot Available or Robot Unavailable popup message. If the robot is unavailable, check the cabling and the network configuration again.
2.2 Enabling Real-Time Data Exchange (RTDE)
The vision controller reads the robot state directly from the UR controller. It connects to the Real-Time Data Exchange (RTDE) port 30004 and reads the joint positions and the TCP pose at 10 Hz (for robot visualization). No Robot State Server program has to run on the robot, but the RTDE service must be enabled and running on the robot.
To check that this service is running, go to Settings -> Security -> Services and make sure that RTDE is enabled.
2.3 Loading the Robot module files
The Photoneo UR robot interface consists of a single script file and several URP template programs:
photoneo_scripts
photoneo_locator.script
photoneo_examples
pho_calibration_basic_loc.urppho_calibration_auto_loc.urppho_main_basic_loc.urppho_main_basic_hand_eye_loc.urppho_main_basic_multi_vs_loc.urppho_main_change_solution_loc.urppho_main_get_status_loc.urppho_main_multiview_dynamic_loc.urppho_main_multiview_static_loc.urppho_main_reuse_scan_loc.urppho_main_change_bbox_loc.urppho_calibration_basic_hand_eye.urp
Copy both folders (the URP programs and the script) to the robot controller. The URP programs include the script through a Script node (type File) at the start of the program. PolyScope keeps a copy of the script inside the URP program. So the copy stored in a URP file can be older than the script file in the module.
Reload the script in every program you use. After you copy the files, open the program and select the Script node that includes photoneo_locator.script. Open the file again from the copied photoneo_scripts folder and save the program. Check that PHO_ROBOT_ID_STR in the loaded script is "UR/L/1.5.0XXXXXXXXXXXXXX".
You can copy the files to the robot controller in 2 ways:
USB flash drive
File transfer protocols such as SCP, FTP or SFTP
USB flash drive approach
Copy the folders from the downloaded module archive to a USB flash drive. Plug the drive into the USB port of the teach pendant or the robot controller.
Click Open -> Program:
Select usbdisk -> Photoneo UR Module -> LS 1.5 -> photoneo_examples:
To copy pho_main_basic_loc.urp to the robot controller, select the file in the list and click Copy.
Go to the target folder on the robot controller and click Paste to copy pho_main_basic_loc.urp there.
Repeat these steps for all template URP programs that you plan to use in your project. Copy the photoneo_scripts folder in the same way.
File transfer protocol approach
You can also copy files to the UR controller remotely, directly from your PC. Use WinSCP, FileZilla or another SFTP client. Use the following configuration for the connection:
Protocol: SFTP
Host: Robot IP address
Port: 22
User:
rootPassword:
easybot
If you prefer a command line, use the following scp command to copy the files:
$ scp -r photoneo_scripts photoneo_examples root@XXX.XXX.XXX.XXX:/programs/
2.4 Tool TCP setup
TCP setup - Locator Studio reads the UR TCP pose during calibration and hand-eye scan requests. The robot reports the tool position according to the TCP configuration on the Installation TCP tab. Locator Studio prefers an “all zeros” tool configuration, because it compensates the TCP offset directly on the vision system side. A zero tool configuration is also recommended for calibration.
The example programs send the flange pose (get_actual_tool_flange_pose()) with the calibration and hand-eye scan requests. So these requests do not depend on the active TCP. If you must use a non-zero tool, use the set_tcp command (see the UR Scripting language manual) to switch between the zeroed and the non-zeroed tool.
3 Robot module
The Robot module is designed for easy integration into existing applications.
Note: We strongly recommend that you read the Photoneo robotic API and Action requests documentation before this section.
3.1 Connection procedures
Warning: This procedure is in the API section of photoneo_locator.script. Do not edit it!
This procedure connects to the Action Request Server on the vision controller at the start of the program. You can send requests only after the connection is established.
Connection procedure |
Description / Usage |
|---|---|
Connect to Action Request Server
pho_wait_for_server(server_ip,port = PHO_LOCATOR_PORT_DEFAULT,max_attempt = 1) |
Description
Opens a new connection to the Action Request Server (vision controller).
Input parameters:
Usage
Call the procedure only once, at the start of the program. You can send requests only after the connection is established.
pho_wait_for_server("192.168.1.1")
Populates
PHO_ERR_CODE - error code [global variable]After the socket is open, the procedure sends the brand ID |
3.2 Request list
This section describes the API calls of the Robot module. These procedures are intended for high-level control of the Locator Studio application. The request ID is the number sent to the vision controller. For a full description of each request, see Action requests.
Note: These procedures are defined in the API section of photoneo_locator.script. Do not edit them!
Note: Scan request and Meshing scan request do not wait for their response. pho_wait_for_scan_completion() reads the response. If you do not call it, the next request reads the response at its start. All other requests wait for their own response before they return.
Note: Only pho_wait_for_scan_completion() has the optional parameter timeout. Its default value -1 means that the timeout for receiving packets is infinite. UR Script cannot detect a closed socket, so in this case the robot program can hang on a receive. All other procedures wait for the response without a timeout.
Calibration requests
Request |
Input variables |
Output variables |
|---|---|---|
Calibration start request (ID 25)
pho_calib_start(solution_id,vision_sys_id) |
solution_id - solution IDvision_sys_id - vision system ID |
|
Calibration add point request (ID 5)
pho_calib_add_point(tcp_pose) |
|
|
Calibration save request (ID 27)
pho_calib_save() |
— |
PHO_ERR_CODE - error code [global variable]pho_calib_acc - resulting calibration accuracy [µm, global variable]pho_camera_pose - resulting camera pose [global variable] |
Calibration stop request (ID 26)
pho_calib_stop() |
— |
|
Locator requests
Request |
Input variables |
Output variables |
|---|---|---|
Scan request (ID 19)
pho_request_scan(vision_sys_id,tcp_pose = PHO_NO_POSE) |
vision_sys_id - vision system IDtcp_pose - flange pose [optional parameter - required for hand-eye vision systems; use get_actual_tool_flange_pose()] |
Note: The response is received by the procedure Wait for scan completion. |
Meshing scan request (ID 30)
pho_request_trigger_scan(vision_sys_id,tcp_pose = PHO_NO_POSE) |
vision_sys_id - vision system IDtcp_pose - flange pose [optional parameter - for hand-eye systems use get_actual_tool_flange_pose()] |
Note: The response is received by the procedure Wait for scan completion or by the next request. |
Reuse last scan request (ID 31)
pho_run_loca_on_last_scan(vision_sys_id) |
|
Note: Waits for its own response. Do not call Wait for scan completion after it. |
Change bounding box request (ID 33)
pho_request_change_bbox(vision_sys_id,bbox_id) |
vision_sys_id - vision system IDbbox_id - bounding box ID |
|
Get objects request (ID 20)
pho_request_get_objects(vision_sys_id,num_of_req_objects) |
vision_sys_id - vision system IDnum_of_req_objects - number of requested object poses (0 = all) |
PHO_ERR_CODE - error code [global variable]pho_object_poses - array of the received object poses as pose variables (p[x,y,z,ax,ay,az]), indexed from 0, up to 100 objects [global variable]pho_number_of_objects - number of received object poses [global variable]pho_dimensions_x - object width [mm, non-CAD solutions, global variable]pho_dimensions_y - object length [mm, non-CAD solutions, global variable]pho_dimensions_rot - object rotation [rad, non-CAD solutions, global variable]pho_nn_label - detected object label [AI solutions, global variable]pho_max_height - object height [mm, Layer solutions, global variable]pho_angle - object angle [rad, Layer solutions, global variable] |
Get all objects
pho_request_get_all_objects(vision_sys_id) |
|
Same as Get objects request with |
Get single object
pho_request_get_single_object(vision_sys_id) |
|
Same as Get objects request with |
Get vision system status request (ID 22)
pho_request_get_vs_status(vision_sys_id) |
|
PHO_ERR_CODE - error code [global variable]pho_num_localized - number of objects localized [global variable]pho_num_ready - number of objects ready for picking [global variable]pho_process_state - 1 = vision system still processing, 0 = finished [global variable] |
Solution requests
Request |
Input variables |
Output variables |
|---|---|---|
Change solution request (ID 9)
pho_request_change_solution(solution_id) |
|
|
Start solution request (ID 10)
pho_request_start_solution(solution_id) |
|
|
Stop solution request (ID 11)
pho_request_stop_solution() |
— |
|
Get running solution request (ID 12)
pho_request_running_solution() |
— |
PHO_ERR_CODE - error code [global variable]pho_running_solution - solution ID [global variable] |
Response receiving procedures
Response receiving procedures |
Input variables |
Output variables |
|---|---|---|
Wait for scan completion
pho_wait_for_scan_completion(timeout = -1) |
|
Note: Reads the response of the last Scan or Meshing scan request. If no request is waiting for a response, it shows a popup and stops the program. |
Communication check
Request |
Input variables |
Output variables |
|---|---|---|
Communication check request (ID 100)
pho_request_comm_check() |
— |
|
Auxiliary procedures
Procedure |
Description |
|---|---|
|
Sets |
|
Returns the error code as text, for example |
Get offset pose is an additional function. It calculates an approach or deapproach offset pose based on the selected method and axis.
Function |
Input parameters |
Returns |
|---|---|---|
Get offset pose
pho_get_offset(pho_object_pose,pho_offset_value,pho_method = PHO_METHOD_DEFAULT,pho_axis_name = PHO_AXIS_NAME_DEFAULT) |
pho_object_pose - target object posepho_offset_value - offset magnitude, in meterspho_method - offset calculation method [optional parameter, one of "Tool Offset", "Tool Plane", "Base Offset", "Base Plane"; default "Base Offset"]pho_axis_name - axis along which the offset is applied [optional parameter, one of "X", "Y", "Z"; default "Z"] |
pose |
Method options:
"Base Offset"- adds the offset along the selected axis in the base coordinate system"Base Plane"- overrides the value along the axis in the base coordinate system (the offset value is the absolute coordinate, in meters)"Tool Offset"- moves the pose back along the selected axis of the object pose (tool coordinate system) by the offset value"Tool Plane"- computes the intersection between the offset plane (base system) and the selected axis of the object pose
Use positive offset values for both the Tool and the Base methods. The function also checks that the object pose, the offset pose and two safety poses 20 mm beyond them are within the safety limits of the robot. If they are not, it shows the popup One or more calculated poses are not reachable. An invalid method or axis name also shows a popup.
For more details on how to use this function to set up the approach and deapproach offsets, see 4.1 Set the approach and deapproach offsets.
3.4 Example programs
The Photoneo UR module contains several URP template programs. They show how to use the requests listed in 3.2 Request list for various use cases. Before you run any of them, reload the script as described in 2.3.
URP example |
Description |
|---|---|
pho_main_basic_locpho_main_basic_hand_eye_loc |
This simple example shows the basic workflow: how to connect to a vision controller, send a scan request, request object poses, receive the object poses and execute picks. The example also shows error handling, because each function returns an error value in |
pho_calibration_basic_locpho_calibration_basic_hand_eyepho_calibration_auto_loc |
Calibration examples. Basic calibration ( Automatic recalibration ( Teach all 9 calibration poses before the first run. The calibration error should usually stay below 3 mm. A higher error usually indicates a systematic problem in the calibration setup. If the error is above the allowed threshold, the save request returns error 467. Important: The calibration object must stay where it was during the first calibration. The calibration ball stays mounted in the same place on the flange or gripper and moves with the robot. The marker pattern stays in the same place in the cell. Otherwise, the automatic recalibration fails. |
|
Same as The |
|
Same as At the start, it checks the running solution with |
|
Same as You can call
These variables are often used for advanced decisions, especially to find the best time to start the pick procedure. The example requests |
|
Static meshing example. It shows how to stitch multiple scans together before localization. This is useful for complex scenes or large objects. The robot stops at each scanning position to trigger and capture a scan. Requirements: Set Procedure:
|
|
Dynamic meshing example. It uses Photoneo Instant Meshing together with the Parallel Structured Light technique of MotionCam-3D. Dynamic meshing cannot be used with standard PhoXi 3D Scanners. Procedure:
|
|
Same as Procedure: A regular scan captures the scene for VS1. Then |
|
Same as Procedure: Prepare the vision system with at least 2 bounding boxes. The |
pho_main_basic_loc - program structure (comments and the approach / deapproach parameter folders are shortened):
Photoneo Locator Initialization
Script: photoneo_locator.script
IP_ADDRESS:="192.168.1.1"
pho_wait_for_server(IP_ADDRESS)
Approach Offset Parameters
APPR_OFFSET:=0.1
APPR_AXIS:="Z"
APPR_METHOD:="Tool Offset"
Deapproach Offset Parameters
DEAPPR_OFFSET:=0.2
DEAPPR_AXIS:="Z"
DEAPPR_METHOD:="Base Offset"
Photoneo Pick and Place Loop
VISION_SYS_ID=1
MoveJ
Scanning
pho_request_scan(VISION_SYS_ID)
pho_wait_for_scan_completion()
NUM_OF_REQ_TAR:=3
pho_request_get_objects(VISION_SYS_ID,NUM_OF_REQ_TAR)
If PHO_ERR_CODE != 0
(insert your own error handling)
Else
increment:=0
Loop increment < pho_number_of_objects
MoveL
Pick_start
Approach
pho_object_pose:=pho_object_poses[increment]
approach:=pho_get_offset(pho_object_pose, APPR_OFFSET, APPR_METHOD, APPR_AXIS)
movej(approach,r=0.0)
Grasp
movel(pho_object_pose,a =0.1, v =0.5 )
Gripper Command
Deapproach
deapproach:=pho_get_offset(pho_object_pose, DEAPPR_OFFSET, DEAPPR_METHOD, DEAPPR_AXIS)
movel(deapproach,a=1.2,v=0.5)
Placing
MoveJ
Before_place
MoveL
Place
Gripper Command
MoveL
Deappr_place
increment:=increment+1
3.5 Error handling
Each request resets PHO_OCCURRED_ERR to False and PHO_ERR_CODE to 0 when its response arrives. If an error occurs while the requested operation runs, the module sets the global variable PHO_OCCURRED_ERR to True and stores the error code in the global variable PHO_ERR_CODE. We recommend that you add error handling for your application after each synchronous request and response receiving procedure.
The module reacts differently to each kind of error:
Error code from the vision controller (for example, 502 No object found): the module only sets
PHO_OCCURRED_ERRandPHO_ERR_CODE. Your program decides what to do.Communication errors (connection failed, wrong response, bad data): the module shows a popup and stops the program, because
PHO_COM_ERR_STOPisTrue.Timeout (5): the module only sets the flag and the error code.
pho_wait_for_scan_completion()without a pending scan: the module shows a popup and stops the program.
To keep the program running after a communication error, set PHO_SKIP_ERR = True in your program. The module then only sets the flag and the error code and clears the socket. Use this only together with your own error handling.
For the error codes with their descriptions and troubleshooting, see Error codes.
The module defines the following error code constants in photoneo_locator.script:
Error code |
UR Script constant |
|---|---|
No error (0) |
PHO_NO_ERROR = 0 |
Service error (1) |
PHO_SERVICE_ERR = 1 |
Unknown request (2) |
PHO_UNKNOWN_REQ = 2 |
Communication error (3) |
PHO_COM_FAILURE = 3 |
Bad data (4) |
PHO_BAD_DATA = 4 |
Timeout (5) |
PHO_TIMEOUT = 5 |
Invalid solution ID (450) |
PHO_INVALID_SOLUTION_ID = 450 |
Another solution running (451) |
PHO_ANOTHER_SOL_RUNNING = 451 |
Deployment not started (452) |
PHO_SOLUTION_START_ERROR = 452 |
Deployment is not running (453) |
PHO_SOLUTION_NOT_RUNNING = 453 |
Deployment did not stop (454) |
PHO_SOLUTION_STOP_ERROR = 454 |
Solution is not complete (455) |
PHO_SOLUTION_INCOMPLETE = 455 |
Invalid robot brand (457) |
PHO_INVALID_BRAND_ID = 457 |
Solution already running (458) |
PHO_SOL_ALREADY_RUNNING = 458 |
Solution access unauthorized (459) |
PHO_SOLUTION_FORBID = 459 |
Invalid vision system (460) |
PHO_INVALID_VS = 460 |
Calibration running (461) |
PHO_CALIB_RUNNING = 461 |
Calibration not running (462) |
PHO_CALIB_NOT_RUNNING = 462 |
Calibration stop error (463) |
PHO_CALIB_STOP_ERROR = 463 |
Calibration start error (464) |
PHO_CALIB_START_ERROR = 464 |
Calibration disabled (465) |
PHO_CALIB_DISABLED = 465 |
Not enough points (466) |
PHO_NOT_ENOUGH_POINTS = 466 |
Calibration accuracy above the allowed threshold (467) |
PHO_ERROR_TOO_HIGH = 467 |
Scanner not available (468) |
PHO_SCANNER_NOT_AVAIL = 468 |
Calibration not allowed (469) |
PHO_CALIB_NOT_ALLOWED = 469 |
The Locator errors (500-511) have no constants in the module. Compare PHO_ERR_CODE with the number.
3.6 Info data and variables
Responses can contain additional values (see Info data). The module stores them in these global variables of photoneo_locator.script:
Key |
Variable |
Unit in robot |
|---|---|---|
4 |
|
mm |
5 |
|
mm |
6 |
|
rad (converted from mrad by the module) |
7 |
|
integer |
8 |
|
mm |
9 |
|
rad (converted from mrad by the module) |
10 |
|
µm |
11 |
|
integer |
12 |
|
integer |
13 |
|
integer |
14 |
|
0 / 1 |
[n] is the index of the object in pho_object_poses (starting from 0). pho_nn_label, pho_max_height and pho_angle contain the value of the last object received. Each Get objects request resets pho_max_height and pho_angle to -1. Keys 1-3 are used only in Bin Picking Studio.
Poses (pho_object_poses, pho_object_pose, pho_camera_pose) are UR poses p[x, y, z, rx, ry, rz] in meters and radians (rotation vector).
Other global variables used by the module:
Variable |
Meaning |
|---|---|
|
Error flag and error code of the last request (see 3.5). |
|
Object poses and their count from the last Get objects request. |
|
Pose of the single object from |
|
Camera pose from Calibration save request. |
|
|
|
|
|
Constant, |
4 Runtime
When the solution is fully configured on the vision controller, finish the remaining steps on the robot side and run the Locator Studio program.
4.1 Set the approach and deapproach offsets
In the Locator Studio example programs, you can set the approach and deapproach offset parameters. The pho_get_offset() function uses them. It is described in 3.3 Pick-related functions.
Input parameters for pho_get_offset():
pho_object_pose- target object posepho_offset_value- offset magnitudepho_method- offset calculation methodpho_axis_name- axis along which the offset is applied
Approach offset configuration
The following variables in the Approach Offset Parameters folder define the approach (the default values of the examples are in brackets):
Variable |
Description |
|---|---|
|
Sets the offset distance in meters (0.1) |
|
Specifies the approach axis ( |
|
Selects the approach method, as a string ( |
Available approach methods:
"Base Offset"- adds the offset along the selected axis in the base coordinate system"Base Plane"- overrides the value along the axis in the base coordinate system"Tool Offset"- moves the pose back along the selected axis of the object pose (tool coordinate system)"Tool Plane"- computes the intersection between the offset plane (base system) and the selected axis of the object pose
Configure the deapproach settings separately in the Deapproach Offset Parameters folder: DEAPPR_OFFSET (0.2), DEAPPR_AXIS ("Z") and DEAPPR_METHOD ("Base Offset").
4.2 Teach positions
Scanning
Pick_start
Before_place
Place
Deappr_place
4.3 Prerequisites
Do a final check before you run the Locator Studio interface from the robot side. Make sure that:
The Locator Studio solution is properly configured on the vision controller
The current script is loaded in the program (see 2.3)
The network setup on the robot side is complete and RTDE is enabled
All vision systems defined in the solution are calibrated
All local poses in the main program are touched up
Gripper commands are added to the Gripper Command folders and work
4.4 Running the pho_main_basic_loc program
Deploy your solution. If the communication is not established yet, the status of the Action Request Client (Robot) on the Deployment page is DISCONNECTED.
Note: We strongly recommend that you reduce the override speed to 20% before you run the program for the first time.
When the connection is established, the Action Request Client status changes to CONNECTED. The sensor should now capture the first scan, and localization should start to find objects.
If there is a pickable object in the scene and the robot controller has received its Cartesian pose, the robot should start to move towards the first object.
If the robot movement looks correct, continue moving the robot towards the first target and check that the path is correct. If the robot stops too far from the object or pushes the object too deep, adjust the object origin or the TCP setup of the tool.
When the robot movement looks correct, set up your own placing routine and slowly increase the speed back to 100%.
The robot should now pick and place objects with the Photoneo Universal Robots interface. When you tune your application further, use the example programs in 3.4 Example programs as a guide.
5 Robot module update
To update an existing Robot module to a version that is compatible with your Locator Studio version, follow these steps:
Load the new script - copy the new version of
photoneo_locator.scriptto the robot controller. In your URP program, select the Script node that includes the old script, open the new file instead and save the program.Review the API changes - read the API changes in the new version of the Robot module carefully. Update the API calls in your main program where needed.
To check the version of photoneo_locator.script, look at the script header (Locator communication library v 1.5.0) and the brand ID PHO_ROBOT_ID_STR.
6 Version and brand ID
Robot module version |
1.5.0 (Locator Studio 1.5) |
Brand ID ( |
|
Action Request Server port |
11003 ( |
Robot state |
Read by the vision controller from RTDE port 30004 |
The module sends the brand ID right after the connection opens. Do not change it. The vision controller uses it to select the matching protocol version. For compatible Locator Studio versions, see the Robot module support matrix.
7 Migration
1.4 -> 1.5: The Info data protocol has changed. Every value is sent with its own key and is stored in the variables listed in 3.6. New variable: pho_nn_label. The brand ID is UR/L/1.5.0XXXXXXXXXXXXXX. Replace the script as described in 5 Robot module update. For details, see LS migration guide 1.4 -> 1.5.
